package com.three.lab.adapter;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.three.lab.R;
import com.three.lab.bean.ClassifyBean;

import java.util.List;

public class ClassifyAdapter extends BaseQuickAdapter<ClassifyBean, BaseViewHolder> {

    private int selPosition = 0;

    public ClassifyAdapter( @Nullable List<ClassifyBean> data) {
        super(R.layout.item_list_classify, data);
    }

    public ClassifyAdapter() {
        super(R.layout.item_list_classify);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, ClassifyBean item) {
        helper.setText(R.id.tv_name,item.getName());
        if (helper.getLayoutPosition() == selPosition) {
            helper.setBackgroundColor(R.id.tv_name,mContext.getResources().getColor(R.color.white))
            .setTextColor(R.id.tv_name,mContext.getResources().getColor(R.color.colorPrimary));
        } else {
            helper.setBackgroundColor(R.id.tv_name,mContext.getResources().getColor(R.color.page_content))
            .setTextColor(R.id.tv_name,mContext.getResources().getColor(R.color.black));
        }
    }

    public void setSelPosition(int selPosition) {
        this.selPosition = selPosition;
    }
}
